package yja.gzw.app.activity

import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.TuijianAdapter
import yja.gzw.app.base.BaseActivity
import yja.gzw.app.databinding.ActivityWodeshoucangBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.model.bean.QueryItem
import yja.gzw.app.viewmodel.Mainviewmodel

class WodeshoucangActivity :BaseActivity<Mainviewmodel, ActivityWodeshoucangBinding>(R.layout.activity_wodeshoucang), TuijianAdapter.OnItemClickListener{

    private lateinit var listadapter2: TuijianAdapter
    override fun initView() {
        viewmodel.onshoucangliebiaowang(UserData.token, mapOf("page" to "1"))

    }

    override fun dataObservese() {
        viewmodel.onshoucangliebiao.observe(this, Observer {
            if(it.code==1){
                binding.review.layoutManager=
                    LinearLayoutManager(this, LinearLayoutManager.VERTICAL,false)
                listadapter2= TuijianAdapter(this,it.data.data,this)
                binding.review.adapter= listadapter2
                binding.review.scrollToPosition(0)
            }else{
                Toast.makeText(this,it.msg, Toast.LENGTH_SHORT).show()
            }

        })


    }

    override fun onItemClick(position: Int, uri: QueryItem) {

    }
}